package com.itheima.score.controller;


import com.itheima.score.entity.ResponseResult;
import com.itheima.score.pojo.User;
import com.itheima.score.service.KsClassService;
import com.itheima.score.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Name UserController
 * @Author BaiXin
 * @Date 2022-10-25 17:46
 */
@RestController
@RequestMapping("/v1/user")
public class UserController {
    @Autowired
    UserService userService;
    @Autowired
    KsClassService ksClassService;

/*    @GetMapping("/findByClassId")
    public ResponseResult findByClassId() {
        ResponseResult result = userService.findAll();
        return result;
    }*/

    @GetMapping("/findByClassId")
    public ResponseResult findByClassId(User user, HttpServletRequest request) {
        Integer classId = (Integer) request.getSession().getAttribute("classId");
        ResponseResult result = userService.findByClassId(classId);
        return result;
    }

    @PostMapping("/addIntegral")
    public ResponseResult addIntegral(@RequestBody User user){
        ResponseResult result =  userService.addIntegral(user);
        return result;
    }
}
